10 KEYOFF:SCREEN0:WIDTH40:COLOR15,1,1:PRINT "Studio 700 Software presents..."
20 REM *** Initialize ***
30 DIM S(36),R(36),N(36)
40 N1 = 36:N2 = 14:N3 = 112
50 FOR X = 1 TO N1 + N2 + N3: READ Z$: NEXT 
60 FOR X = 1 TO N1
70 READ S(X),L:R(X) = S(X):N(X) = S(X) + L - 1
80 NEXT X
90 CLS:PRINT"ELIZA - The Computer Psychiatrist":PRINT
100 PRINT"Original ELIZA by Joseph Weizenbaum":PRINT "MIT, 1965"
110 PRINT:PRINT "MSX version by:":PRINT "Claudio H. Picolo, 2020" 
120 PRINT : PRINT "----------------------------------------";
130 PRINT
140 PRINT "Why have you requested this session?"
150 INPUT I$
160 I$=" "+I$+"  "
170 REM *** LOSE EXTRANEOUS INPUT CHARS ***
180 FOR L=1 TO LEN(I$)
190 IF MID$(I$,L,1)="'"THEN I$=LEFT$(I$,L-1)+RIGHT$(I$,LEN(I$)-L):GOTO 190
200 IF L+4<=LEN(I$)THEN IF MID$(I$,L,4)="shut" THEN PRINT"Goodbye!":END
210 NEXT L
220 IF I$=P$ THEN PRINT "Please don't repeat yourself!":GOTO 150
230 REM  *** Get keywords ***
240 RESTORE
250 S=0
260 FOR K=1 TO N1
270 READ K$
280 IF S>0 THEN 320
290 FOR L=1 TO LEN(I$)-LEN(K$)+1
300 IF MID$(I$,L,LEN(K$))=K$ THEN S=K:T=L:F$=K$
310 NEXT L
320 NEXT K
330 IF S>0 THEN K=S:L=T:GOTO 350
340 K=36:GOTO 550
350 RESTORE:FOR X=1 TO N1:READ Z$:NEXT
360 C$=" "+RIGHT$(I$,LEN(I$)-LEN(F$)-L+1)+" "
370 FOR X=1 TO N2/2
380 READ S$,R$
390 FOR L=1 TO LEN(C$)
400 IF L+LEN(S$)>LEN(C$)THEN 450
410 IF MID$(C$,L,LEN(S$))<>S$THEN 450
420 C$=LEFT$(C$,L-1)+R$+RIGHT$(C$,LEN(C$)-L-LEN(S$)+1)
430 L=L+LEN(R$)
440 GOTO 490
450 IF L+LEN(R$)>LEN(C$)THEN 490
460 IF MID$(C$,L,LEN(R$))<>R$THEN 490
470 C$=LEFT$(C$,L-1)+S$+RIGHT$(C$,LEN(C$)-L-LEN(R$)+1)
480 L=L+LEN(S$)
490 NEXT L
500 NEXT X
510 IF MID$(C$,2,1)=" "THEN C$=RIGHT$(C$,LEN(C$)-1)
520 FOR L=1 TO LEN(C$)
530 IF MID$(C$,L,1)="!"THEN C$=LEFT$(C$,L-1)+RIGHT$(C$,LEN(C$)-L):GOTO 530
540 NEXT L
550 RESTORE:FOR X=1 TO N1+N2:READ Z$:NEXT X
560 FOR X=1 TO R(K):READ F$:NEXT X
570 R(K)=R(K)+1:IF R(K)>N(K) THEN R(K)=S(K)
580 IF RIGHT$(F$,1)<>"*"THEN PRINT F$:P$=I$:GOTO 150
590 PRINT LEFT$(F$,LEN(F$)-1);C$
600 P$=I$:GOTO 150
610 DATA "Can you", "Can I", "You are", "You're", "I don't", "I feel"
620 DATA "Why don't you", "Why can't I", "Are you", "I can't", "I am", "I'm "
630 DATA "You ", "I want", "What", "How", "Who", "Where", "When", "Why"
640 DATA "Name", "Cause", "Sorry", "Dream", "Hello", "Hi ", "Maybe"
650 DATA "No", "Your", "Always", "Think", "Alike", "Yes", "Friend"
660 DATA "Computer", "no key found"
670 DATA " are ", " am ", " were ", " was ", " you ", " I ", "your ", "my "
680 DATA " I've ", " you've ", " I'm ", " you're "
690 DATA " me ", " !you "
700 DATA "Don't you believe that                  I can*"
710 DATA "Perhaps you would like to               be able to*"
720 DATA "You want me to be able to*"
730 DATA "Perhaps you don't want to*"
740 DATA "Do you want to be able to*"
750 DATA "What makes you think I am*"
760 DATA "Does it please you to believe           I am*"
770 DATA "Perhaps you would like to be*"
780 DATA "Do you sometimes wish you were*"
790 DATA "Don't you really*"
800 DATA "Why don't you*"
810 DATA "Do you wish to be able to*"
820 DATA "Does that trouble you?"
830 DATA "Tell me more about such feelings"
840 DATA "Do you often feel*"
850 DATA "Do you enjoy feeling*"
860 DATA "Do you really believe I don't*"
870 DATA "Perhaps in good time I will*"
880 DATA "Do you want me to*"
890 DATA "Do you think you should                 be able to*"
900 DATA "Why can't you*"
910 DATA "Why are you interested in whether       or not I am*"
920 DATA "Would you prefer if I were not*"
930 DATA "Perhaps in your fantasies I am*"
940 DATA "How do you know you can't*"
950 DATA "Have you tried?"
960 DATA "Perhaps you can now*"
970 DATA "Did you come to me because              you are*"
980 DATA "How long have you been*"
990 DATA "Do you believe it is normal             to be*"
1000 DATA "Do you enjoy being*"
1010 DATA "We were discussing you, not me."
1020 DATA "Oh, I*"
1030 DATA "You're not really talking about me,     are you?"
1040 DATA "What would it mean to you if you got*"
1050 DATA "Why do you want*"
1060 DATA "Suppose you soon got*"
1070 DATA "What if you never got*"
1080 DATA "I sometimes also want*"
1090 DATA "Why do you ask?"
1100 DATA "Does that question interest you?"
1110 DATA "What answer would please you the most?"
1120 DATA "What do you think?"
1130 DATA "Are such questions on your mind often?"
1140 DATA "What is it that you really              want to know?"
1150 DATA "Have you asked anyone else?"
1160 DATA "Have you asked such questions before?"
1170 DATA "What else comes to mind when            you ask that?"
1180 DATA "Names don't interest me."
1190 DATA "I don't care about names...             Please go on."
1200 DATA "Is that the real reason?"
1210 DATA "Don't any other reasons come to mind?"
1220 DATA "Does that reason explain anything else?"
1230 DATA "What other reasons might there be?"
1240 DATA "Please don't apologize!"
1250 DATA "Apologies are not necessary."
1260 DATA "What feelings do you have when          you apologize?"
1270 DATA "Don't be so defensive!"
1280 DATA "What does that dream suggest to you?"
1290 DATA "Do you dream often?"
1300 DATA "What persons appear in your dreams?"
1310 DATA "Are you disturbed by your dreams?"
1320 DATA "How do you do. please state             your problem."
1330 DATA "You don't seem quite certain."
1340 DATA "Why the uncertain tone?"
1350 DATA "Can't you be more positive?"
1360 DATA "You aren't sure?"
1370 DATA "Don't you know?"
1380 DATA "Are you saying 'no' just to be negative?"
1390 DATA "You are being a bit negative."
1400 DATA "Why not?"
1410 DATA "Are you sure?"
1420 DATA "Why no?"
1430 DATA "Why are you concerned about my*"
1440 DATA "What about your own*"
1450 DATA "Can you think of an example?"
1460 DATA "When?"
1470 DATA "What are you thinking of?"
1480 DATA "Really,...always?"
1490 DATA "Do you really think so?"
1500 DATA "But you are not sure you*"
1510 DATA "Do you doubt you*"
1520 DATA "In what way?"
1530 DATA "What similarity do you see?"
1540 DATA "What does the similarity suggest to you?"
1550 DATA "What other connections do you see?"
1560 DATA "Could there really be some connection?"
1570 DATA "How?"
1580 DATA "You seem quite positive."
1590 DATA "Are you sure?"
1600 DATA "Hmmm...I see."
1610 DATA "I understand."
1620 DATA "Do you have any friends?"
1630 DATA "Do your friends worry you?"
1640 DATA "Do they pick on you?"
1650 DATA "Are your friends a source of anxiety?"
1660 DATA "Do you impose your problems on          your friends?"
1670 DATA "Perhaps your dependence on friends      worries you."
1680 DATA "Do computers worry you?"
1690 DATA "Are you talking about me in particular?"
1700 DATA "Are you frightened by machines?"
1710 DATA "Why do you mention computers?"
1720 DATA "What do you think machines have to do   with your problems?"
1730 DATA "Don't you think computers can help you?"
1740 DATA "What is it about machines that          worries you?"
1750 DATA "Do you feel intense                     psychological stress?"
1760 DATA "What does that suggest to you?"
1770 DATA "I see."
1780 DATA "I'm not sure I understand you fully."
1790 DATA "Now, please clarify yourself."
1800 DATA "Can you elaborate on that?"
1810 DATA "That is quite interesting."
1820 REM  *** To find correct replies ***
1830 DATA 1,3,4,2,6,4,6,4,10,4,14,3,17,3,20,2,22,3,25,3
1840 DATA 28,4,28,4,32,3,35,5,40,9,40,9,40,9,40,9,40,9,40,9
1850 DATA 49,2,51,4,55,4,59,4,63,1,63,1,64,5,69,5,74,2,76,4
1860 DATA 80,3,83,7,90,3,93,6,99,7,106,6
